<script>
export default {
  name: "GoodList",
  methods: {
    jionCart(goods){
        this.$store.commit('JOIN_CART',goods);
        this.$router.push("/myCart");
    }
  }
}
</script>

<template>
<div>
  <h3 v-if="$store.state.goods.goodsList.length===0">暂无商品</h3>
  <template v-else>
    <div v-for="item in $store.state.goods.goodsList" id="item.goodsId">
        <p>商品名称{{item.goodsName}}</p>
        <p>商品价格{{item.goodsPrice | currency}}</p>
        <p>上架时间{{item.addTime | date}}</p>
        <button @click="jionCart(item)">加入购物车</button>
    </div>
  </template>
</div>
</template>

<style scoped>

</style>